



cd "D:\Dropbox\book_welfare\replication"



**********************************
* find growing genres - Bookstat  
**********************************






use  data\bookstat_sales_gender_pyear_genre_asin.dta, clear 

		collapse (sum) q qm=q_male qname=q_name, by(pyear genre )
		

		
		keep if pyear>=1960 & pyear<=2021
		egen Q=sum(q), by(pyear  )
		gen s=q/Q
		gen ls = ln(s)
		
		
		
	gen genre1=genre 
	* replace genre1 = "other" if QQ<2.5e+07
		
preserve 
	egen gno=group(genre)
	collapse (mean) gno, by(genre) 
	tempfile genre 
	save `genre'
restore 



	
egen gno=group(genre)
		reg s i.gno#c.pyear i.gno 

parmest, norestore 


split parm, parse(".gno#c." "b.gno#c.")
gen gno=real(parm1)
drop if gno==. 

merge 1:1 gno using `genre'



graph bar (mean) estimate if estimate~=., over(genre, sort(estimate) descending label(angle(forty_five) labsize(vsmall))) scheme(lean2) yline(1) ytitle(annual sales share growth)


gsort -estimate 
gen gno1 = _n 
twoway (scatter estimate gno1) (rcap max95 min95 gno1), scheme(lean2) legend(off) xlabel( 1	"Romance" ///
2	"Mystery, Thriller & Suspense" ///
3	"Literature & Fiction" ///
4	"Science Fiction & Fantasy" ///
5	"Business & Money" ///
6	"Teen & Young Adult" ///
7	"Kindle eBooks" ///
8	"Self-Help" ///
9	"Health, Fitness & Dieting" ///
10	"Education & Teaching" ///
11	"Comics & Graphic Novels" ///
12	"Cookbooks, Food & Wine" ///
13	"Biographies & Memoirs" ///
14	"Christian Books & Bibles" ///
15	"Parenting & Relationships" ///
16	"Computers & Technology" ///
17	"Lesbian, Gay, Bisexual & Transgender" ///
18	"Crafts, Hobbies & Home" ///
19	"Calendars" ///
20	"Law" ///
21	"Kindle Short Reads" ///
22	"Nonfiction" ///
23	"Deals in Books" ///
24	"Test Preparation" ///
25	"Foreign Languages" ///
26	"Books on CD" ///
27	"Libros en español" ///
28	"Sports & Outdoors" ///
29	"Medical Books" ///
30	"Engineering & Transportation" ///
31	"Travel" ///
32	"History" ///
33	"Humor & Entertainment" ///
34	"other" ///
35	"Textbooks" ///
36	"missing" ///
37	"Politics & Social Sciences" ///
38	"Science & Math" ///
39	"Religion & Spirituality" ///
40	"Arts & Photography" ///
41	"Reference" ///
42	"Children's Books", labsize(vsmall) angle(forty_five) noticks) xtitle("") ytitle(growth in genre sales share across vintages) t1(Bookstat)


graph export latex_text\figures\genre_sales_growth_bs_asin.pdf, as(pdf) name("Graph") replace 





**********************************
* find growing genres - Goodreads  
**********************************





use data\books_year.dta, clear  


		keep if year>=2007 & year<=2016
		keep if pubyr >=1960 & pubyr<=2016 
	
		drop if fbookp==. 

		collapse (sum) q , by(pubyr genre1 )
		
		egen Q=sum(q), by(pubyr)
		gen s=q/Q
		
		egen gno=group(genre)
		rename pubyr pyear 
		reg s i.gno#c.pyear i.gno 
		
		
	preserve 
		collapse (mean) gno, by(genre1)
		tempfile g 
		save `g'
	restore 
	
	 preserve 
		parmest, norestore 


		split parm, parse(".gno#c." "b.gno#c.")
		gen gno=real(parm1)
		drop if gno==. 

		 merge 1:1 gno using `g'
			replace genre1=proper(genre1)
			replace genre1=subinstr(genre1,"-"," ",.)

		graph bar (mean) estimate if estimate~=., over(genre1, sort(estimate) descending label(angle(forty_five) labsize(small))) scheme(lean2) yline(1) ytitle(annual sales share growth)
		
gsort -estimate 
gen gno1 = _n 		
twoway (scatter estimate gno1) (rcap max95 min95 gno1), scheme(lean2) legend(off) xlabel( 1	"Romance" 2	"Young Adult" 3	"Fantasy" 4	"Mystery" 5	"Comics" 6	"Missing" 7	"Non Fiction" 8	"History" 9	"Poetry" 10	"Children" 11	"Fiction",  labsize(small) angle(forty_five) noticks) xtitle("") ytitle(growth in genre sales share across vintages) t1(Goodreads)

		
		
		graph export latex_text\figures\genre_sales_growth_gr.pdf, as(pdf) name("Graph") replace 
	restore 
		
		
				